/*
-----------------------------------------------------------------------------
This source file is part of as4game
	(ActionScript For Game Engine)
For the latest info, see http://as4game.googlecode.com

Copyright (c) 2000-2011 Hproof Software Ltd

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-----------------------------------------------------------------------------
*/
package org.as4game.common.data
{

	/**
	 * Pool 是一个内存分配池
	 * <li> 维护 maxSize 个分配池, 当释放时, 添加到池中, 分配时, 优先从池中获取
	 * <li> 仅大对象需要考虑用池来管理, 小对象不要用这个
	 */
	public class Pool
	{
		private var _pool:Vector;
		private var _free:LinkNode;
		
		/**
		 */
		public function Pool():void{
			_pool = new Vector.<LinkNode>();
			_free = null;
		}
		
		/**
		 * 分配
		 */
		public function alloc():LinkNode{
			if( _free == null ){
				_extend();
			}
			
			var unit:LinkNode = _free;
			_free = _free.next;
			return unit;
		}
		
		/**
		 * 扩展
		 */
		private function _extend():void{
		}
		
		/**
		 * 释放
		 */
	}
}